import serial
import time
import sys


try:
    ser = serial.Serial("/dev/ttyACM0", baudrate=115200, timeout=1)
    ser.flushInput()
except Exception as e:
    print(e)
    sys.exit(0)

try:
    ser.write(("PAGE"+'\r\n').encode())
    ip = sys.argv[1]
    print(ip)
    localtime = time.asctime(time.localtime(time.time()))	#打印当前时间
    ser.write((f'IP:&n{ip}\r\n').encode())
    print("FINISH")
except Exception as e:
    print(e)
    sys.exit(0)
